function removeAllChildrenOfId(id) {
	var element = document.getElementById(id);

	if (!element) return;

	removeAllChildrenOfNode(element);
}
function removeAllChildrenOfNode(node) {
	if (!node) return;

	while (node.hasChildNodes()) {
		node.removeChild(node.firstChild);
	}
}
function appendChildToId(id, child) {
	var element = document.getElementById(id);
	if (!element) return;

	element.appendChild(child);
}
function buildTextNode(text) {
	return document.createTextNode(text);
}
function buildTextList(objects) {
	var list = "";
	for (var i = 0; i < objects.length; ++i) {
		var object = objects[i];
		list += object;
		if (i < objects.length -1) list += ", ";
	}
	return document.createTextNode(list);
}
function buildTableCell(node) {
	var tableCell = document.createElement("td");
	tableCell.appendChild(node);
	return tableCell;
}
function buildButton(text, action) {
	var button = document.createElement("button");
	button.appendChild(document.createTextNode(text));
	button.onclick = action;
	return button;
}
function buildRadio(name, value) {
	var radio = document.createElement("input");
	radio.type = "radio";
	radio.name = name;
	radio.value = value;
	return radio;
}
function buildOption(text, value) {
	var option = document.createElement("option");
	option.appendChild(document.createTextNode(text));
	option.value = value;
	return option;
}
